from django.db import models

# Create your models here.
from django.db import models

# Create your models here.
class User(models.Model):
    uid=models.CharField(verbose_name='用户的唯一标识',primary_key=True,max_length=36,)
    username=models.CharField(verbose_name='账号',max_length=11,blank=False,null=False,unique=True)
    password=models.CharField(verbose_name='密码',max_length=32,blank=False,null=False)
    email=models.EmailField(verbose_name='邮箱',blank=False,null=False)
    phone=models.CharField(verbose_name='手机号',max_length=11,blank=False,null=False)
    role=models.IntegerField(verbose_name='角色',choices=((0,'普通用户'),(1,'管理员'),(3,'超级管理员')),
                             default=0)
    is_delete=models.BooleanField(verbose_name='是否删除',default=False)
    createTime=models.DateTimeField(verbose_name='创建时间',auto_now_add=True)
    avatar=models.ImageField(verbose_name='用户头像',null=True,blank=True)
    objects=models.Manager()
    class Meta:
        db_table='user'


class UserInfo(models.Model):
    username=models.OneToOneField(to=User,to_field='username',on_delete=models.CASCADE)
    nickName=models.CharField(verbose_name='用户昵称',max_length=32,blank=True,null=True)
    age=models.IntegerField(verbose_name='年龄',blank=True,null=True)
    sex=models.BooleanField(verbose_name='性别',default=True)
    city=models.CharField(verbose_name='所在城市',max_length=32,blank=True,null=True)
    objects=models.Manager()
    class Meta:
        db_table='userInfo'

class Feedback(models.Model):
    username=models.ForeignKey(to=User,to_field='username',on_delete=models.CASCADE)
    type=models.CharField(verbose_name='反馈类型',max_length=8,blank=False,null=False)
    content=models.TextField(verbose_name='反馈内容',blank=False,null=False)
    contact=models.CharField(verbose_name='联系方式',max_length=32,blank=True,null=True)
    class Meta:
        db_table='feedback'

class LocationHistory(models.Model):
    username=models.ForeignKey(to=User,to_field='username',on_delete=models.CASCADE)
    submit_time=models.DateTimeField(verbose_name='提交时间',auto_now_add=True)
    address=models.CharField(verbose_name='定位地址',max_length=64,blank=False,null=False)
    spend_time=models.CharField(verbose_name='全程花费时间',max_length=64,blank=False,null=False)
    class Meta:
        db_table='locationhistory'